<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>  
<!DOCTYPE html>
<!-- saved from url=(0047)http://192.168.1.42:8080/shop-pc/manage/address -->
<html lang="zh"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		
	    <meta http-equiv="Content-Language" content="zh-CN">
	    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
	    <meta name="description" content="shop">
	    <meta name="author" content="letsun">
	    
	    <title>配送地址</title>

		<%@ include file ="../init.jsp" %>
		<script src="${resources}/js/jqPaginator.min.js"></script>
		<link rel="stylesheet" type="text/css" href="${resources}/css/address.css">
	<style>
		#notdata{
			display: none;
			text-align: center;
			padding-bottom: 100px;
		}
		#notdata img{
			margin-top: 100px;
			width:200px;
		}
		#notdata p{
			color: #E6E6E6;
			font-size:18px;
			height:40px;
			line-height:40px;
		}
		#notdata div{
			color: #E6E6E6;
		}
		#notdata .addAddress{
			color: #fff;
			font-size: 18px;
			padding: 0 10px;
			height:30px;
			line-height:30px;
			background-color: #de2525;
			display: inline-block;
			border-radius: 8px;
		}</style>

 	</head>

 	<body>
		<%@ include file ="../header_1.jsp" %>

		
		<div class="container">
			<div class="row">
				<div class="col-md-1">
					<%@ include file = "../menu.jsp" %>
 				</div>
				<div class="col-md-11">

	<!-- page-header -->
	<div class="page-header">
		<div class="page-comm">
	 		<div class="mt"> 
	 	 		<h3>收货地址</h3>
	 	 	</div>
 	 		<div class="mc pull-right">
				<a href="${path}/manage/myCenter/create" class="e-btn add-btn btn-5">新增收货地址</a>
			</div>
	 	 	<div class="mc">
	 	 		<p>设置好轻松购信息，就可以在商品页面直接下单 ，购物从此变得简单快乐。</p>
	 	 	</div>
		</div>	
	</div>
	<!--/.page-header -->
	
	<!-- page-content -->
	<div class="page-content">
		<div class="page-comm">
			
			<div class="alert alert-success">
				<span class="ftx-03">您已创建
					<span id="addressNum_top" class="ftx-02">1</span>个收货地址，最多可创建
					<span class="ftx-02">20</span>个
				</span>
			</div>



			<div class="mc" style="margin-top:10px;padding-bottom: 60px;position: relative">
			 	<table class="table data-table">
					<thead>
						<tr>
							<th>收货人</th>
							<th>详细地址</th>
							<th>电话/手机</th>
							<th>操作</th>
							<th></th>
						</tr>
					</thead>
					<tbody  id="pageCon">
					</tbody>
				</table>
			</div>
			
		</div>
		<div id="notdata">
			<img src="${resources}/images/10_10_03.png" alt="">
			<p>土豪，查找不到你的收货地址</p>
			<a class="addAddress" href="${path}/manage/myCenter/create">添加收货地址</a>
		</div>
	</div>
	<!--/.page-content -->
				</div>
 			</div>
 		</div>
 		
<%@ include file="../footer.jsp" %>
<script>
var selData = ({
	pageNumber : 1
})
	function paging(cfg) {
		var paginator = $("#pageCon");

		paginator.jqPaginator({
			totalCounts: 500,//总条目数
			pageSize: 3,//每一页显示的条目数
			visiblePages: 5,//分多少页
			currentPage: 1,//当前页数
			first: '<li class="first"><a href="javascript:void(0);">首页<\/a><\/li>',
			prev: '<li class="prev"><a href="javascript:void(0);">上一页<\/a><\/li>',
			next: '<li class="next"><a href="javascript:void(0);">下一页<\/a><\/li>',
			last: '<li class="last"><a href="javascript:void(0);">末页<\/a><\/li>',
			page: '<li class="page"><a href="javascript:void(0);">{{page}}<\/a><\/li>',
			wrapper: '<ul class="pageBtn"></ul>',

			//页面加载和点击页码时请求数据
			onPageChange: function (num) {
				selData.pageNumber= num;
				$.get(cfg.url, "", function (res) {
				 if (res.msg == 0) {
					 notdata();
					 return;
				 }
				 $("#addressNum_top").html(res.msg);
				 var html = "";
				 //重新配置分页的总条目数
				 var count = -(res.msg) * (-1);
				 paginator.jqPaginator('option', {
					 totalCounts: count
				 });
				 if(res.code=="111"){
					 notdata();
					 return ;
				 }
				 for (var i = 0; i < res.result.length; i++) {
					 	var address = res.result[i];
						html += '<tr>';
						html +='<td>'+address.name+'</td>';
						html +='<td>'+address.address+"&nbsp;"+address.street+'</td>';
						html +='<td>'+address.telephone+'</td>';
						html +='<td>';
						html +='<span>';
						html +='<a href="${path}/manage/myCenter/update/'+address.id+'">编辑</a>';
						html +='</span> | ';
						html +='<span>';
						if(address.isDefault==1){
							html +='<a onclick="alert(&#39默认地址不能被删除 !&#39;);return false;" href="${path}/manage/myCenter/deleteaddress/'+address.id+'">删除</a>';
						}else{
							html +='<a  href="${path}/manage/myCenter/deleteaddress/'+address.id+'">删除</a>';
						}
						html +='</span>';
						html +='</td>';
						html +='<td>';
						if(address.isDefault==1){
							html +='<span class="label label-danger">默认地址</span>';
						}
						html +='</td>';
						html +='</tr>';
				 }
				 $("#pageCon").append(html);
				 });

			/* 	setTimeout(function(){
					var html = "";

					for (var i = 0; i < 3; i++) {
						html += '<tr>'+
							'<td>asdfa</td>'+
							'<td>浙江省金华市磐安县asdfasdfasdf</td>'+
							'<td>159****2558</td>'+
							'<td>'+
							'<span>'+
							'<a href="新增地址.html">编辑</a>'+
							'</span> | '+
							'<span>'+
							'<a onclick="alert(&#39默认地址不能被删除 !&#39;);return false;" href="http://192.168.1.42:8080/shop-pc/manage/address/delete/59">删除</a>'+
							'</span>'+
							'</td>'+
							'<td>'+
							'<span class="label label-danger">默认地址</span>'+
							'</td>'+
							'</tr>';
					}

					$("#pageCon").append(html);
				},30); */
			}
		});
	}
	paging({url: "${path}/manage/myCenter/addressData"});
	function notdata() {
		$(".page-comm:eq(1)").html($("#notdata").show());
	}
</script>



</body></html>